package com.zhengshang.api.controller.goodsshop;

import com.zhengshang.common.core.domain.AjaxResult;
import com.zhengshang.security.service.TokenService;
import com.zhengshang.third.pinduoduo.PinDuoDuoUtils;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Api(tags = "基础模块-拼多多接口")
@Controller
@RequestMapping("/pinduoduo")
public class AppPinduoduoController {

    @Autowired
    private PinDuoDuoUtils pinDuoDuoUtils;

    @Autowired
    private TokenService tokenService;


    /**
     * 获取授权Url
     */
    @GetMapping(value = "/getAppOauthUrl")
    @ResponseBody
    public AjaxResult getAppOauthUrl(String redirectUri, String state) {
        String oauthUrl = pinDuoDuoUtils.getAppOauthUrl(redirectUri, state);
        return AjaxResult.success("获取成功", oauthUrl);
    }


    /**
     * 物料搜索
     */
    @GetMapping(value = "/goodsSearch")
    @ResponseBody
    public AjaxResult goodsSearch(String goodsName, Integer page, Integer sortType, Boolean withCoupon) {
        return pinDuoDuoUtils.goodsSearch(goodsName, page, sortType, withCoupon);
    }
}
